/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package edu.cmu.mism.dgjava.data.models.option.impl;

import edu.cmu.mism.dgjava.data.models.option.Derivitives;
import edu.cmu.mism.dgjava.data.models.option.OptionModelPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

/**
 * <!-- begin-user-doc --> An implementation of the model object '
 * <em><b>Derivitives</b></em>'. <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.cmu.mism.dgjava.data.models.option.impl.DerivitivesImpl#getVolatility <em>Volatility</em>}</li>
 *   <li>{@link edu.cmu.mism.dgjava.data.models.option.impl.DerivitivesImpl#getRiskFreeRate <em>Risk Free Rate</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class DerivitivesImpl extends EObjectImpl implements Derivitives {
	/**
	 * The default value of the '{@link #getVolatility() <em>Volatility</em>}' attribute.
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @see #getVolatility()
	 * @generated
	 * @ordered
	 */
	protected static final double VOLATILITY_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getVolatility() <em>Volatility</em>}' attribute.
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @see #getVolatility()
	 * @generated
	 * @ordered
	 */
	protected double volatility = VOLATILITY_EDEFAULT;

	/**
	 * The default value of the '{@link #getRiskFreeRate() <em>Risk Free Rate</em>}' attribute.
	 * <!-- begin-user-doc --> <!--
	 * end-user-doc -->
	 * @see #getRiskFreeRate()
	 * @generated
	 * @ordered
	 */
	protected static final double RISK_FREE_RATE_EDEFAULT = 0.0;

	/**
	 * The cached value of the '{@link #getRiskFreeRate() <em>Risk Free Rate</em>}' attribute.
	 * <!-- begin-user-doc --> <!--
	 * end-user-doc -->
	 * @see #getRiskFreeRate()
	 * @generated
	 * @ordered
	 */
	protected double riskFreeRate = RISK_FREE_RATE_EDEFAULT;

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	protected DerivitivesImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OptionModelPackage.Literals.DERIVITIVES;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	public double getVolatility() {
		return volatility;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	public void setVolatility(double newVolatility) {
		double oldVolatility = volatility;
		volatility = newVolatility;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OptionModelPackage.DERIVITIVES__VOLATILITY, oldVolatility, volatility));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	public double getRiskFreeRate() {
		return riskFreeRate;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	public void setRiskFreeRate(double newRiskFreeRate) {
		double oldRiskFreeRate = riskFreeRate;
		riskFreeRate = newRiskFreeRate;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OptionModelPackage.DERIVITIVES__RISK_FREE_RATE, oldRiskFreeRate, riskFreeRate));
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OptionModelPackage.DERIVITIVES__VOLATILITY:
				return getVolatility();
			case OptionModelPackage.DERIVITIVES__RISK_FREE_RATE:
				return getRiskFreeRate();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OptionModelPackage.DERIVITIVES__VOLATILITY:
				setVolatility((Double)newValue);
				return;
			case OptionModelPackage.DERIVITIVES__RISK_FREE_RATE:
				setRiskFreeRate((Double)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OptionModelPackage.DERIVITIVES__VOLATILITY:
				setVolatility(VOLATILITY_EDEFAULT);
				return;
			case OptionModelPackage.DERIVITIVES__RISK_FREE_RATE:
				setRiskFreeRate(RISK_FREE_RATE_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OptionModelPackage.DERIVITIVES__VOLATILITY:
				return volatility != VOLATILITY_EDEFAULT;
			case OptionModelPackage.DERIVITIVES__RISK_FREE_RATE:
				return riskFreeRate != RISK_FREE_RATE_EDEFAULT;
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (volatility: ");
		result.append(volatility);
		result.append(", riskFreeRate: ");
		result.append(riskFreeRate);
		result.append(')');
		return result.toString();
	}

	/**
	 * @generated NOT
	 */
	@Override
	public Object clone() {
		try {
			return super.clone();
		} catch (CloneNotSupportedException e) {
			return null;
		}
	}

} // DerivitivesImpl
